﻿@model ITProject.WebUI.Models.ProjectUser.ProjectUserFunctionalRequirementViewModel
@{

    ViewBag.Title = "Wymaganie funkcjonalne";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@using ITProject.WebUI.Models.ProjectUser
<h2>Panel użytkownika projektu @ViewData["projectName"].ToString()</h2>
<div class="Pmenu">
@Html.Partial(MVC.Shared.Views.Partials._ProjectMenuControl,
    new ITProject.WebUI.Models.Project.ProjectMenuViewModel { ProjectName = ViewData["ProjectName"].ToString(), Role=(ITProject.Domain.UserRole)ViewData["Role"] })
</div>



<div class="PAmenu">
@Html.Partial(MVC.Shared.Views.Partials._ProjectUserMenu, new List<string> { "WF", ViewData["ProjectName"].ToString() })
@*@Html.ActionLink("Zarządzaj użytkownikami",MVC.ProjectAdmin.ActionNames.ManageTeam, MVC.ProjectAdmin.Name, new { projectName = Model }, null)*@
</div>
<div class="PAplane"> 
<div class="wf">

<table width="100%">
<tr>
<td class="wftitletd">@Html.LabelFor(model=>model.Name)</td><td class="wftexttd">@Html.DisplayFor(model=>model.Name)</td></tr>
<tr><td class="wftitletd">@Html.LabelFor(model=>model.Actors)</td><td class="wftexttd">@Html.DisplayFor(model=>model.Actors)</td></tr>

<tr><td class="wftitletd">@Html.LabelFor(model=>model.Priority)</td><td class="wftexttd">@Html.DisplayFor(model=>model.Priority)</td></tr>
<tr><td class="wftitletd">@Html.LabelFor(model=>model.Author)</td><td class="wftexttd">@Html.DisplayFor(model=>model.Author)</td></tr>
<tr><td class="wftitletd">@Html.LabelFor(model=>model.DateOfCreate)</td><td class="wftexttd">@Html.DisplayFor(model=>model.DateOfCreate)</td></tr>
<tr><td class="wftitletd">@Html.LabelFor(model=>model.DateOfLastModification)</td><td class="wftexttd">@Html.DisplayFor(model=>model.DateOfLastModification)</td>

</tr>
</table>
</div>
<div class="wf">
<span class="wftitle">@Html.LabelFor(model=>model.Description)</span>
<span class="wftext">@Html.DisplayFor(model=>model.Description)</span>

<span class="wftitle">@Html.LabelFor(model=>model.InitConditions)</span>
<span class="wftext">@Html.DisplayFor(model=>model.InitConditions)</span>

<span class="wftitle">@Html.LabelFor(model=>model.FinalConditions)</span>
<span class="wftext">@Html.DisplayFor(model=>model.FinalConditions)</span>
</div>

<div class="wf">
<span class="wftitle">@Html.LabelFor(model=>model.Scenarios)</span>
@foreach (var gl in Model.Scenarios)
{
    <span class="wftext">@Html.DisplayFor(model => gl.Prefix) @Html.DisplayFor(model => gl.Text)</span>

}
</div>
<div class="wf">
<span class="wftitle">Wyjątki i rozszerzenia</span>
@{
    ProjectUserScenariosViewModel dziecko;
    foreach(var gl in Model.Scenarios)
    {
        foreach(var ex in gl.Extensions)
        {
            <span class="wftext">
            @Html.DisplayFor(exw=>ex.Prefix)
            @Html.DisplayFor(exw=>ex.Text)
            </span>
            if(ex.Extensions!=null && ex.Extensions.Count!=0)
            {
                dziecko=ex.Extensions.ToList()[0];
            }else
            {
                dziecko = null;
            }
            int i=0;
            while(dziecko != null)
            {
                int span = dziecko.Prefix.Length * 5;
                string span2 = "padding-left:" + span + "px";
                <span class="wftext" style=@span2 >
                @Html.DisplayFor(exw => dziecko.Prefix)
                @Html.DisplayFor(exw => dziecko.Text)
                </span>
                if (dziecko.Extensions != null && dziecko.Extensions.Count != 0)
                {

                    dziecko = dziecko.Extensions.ToList()[0];
                    i=0;
                    continue;
                }
                i++;
                if (dziecko.Parent.Extensions.ToList().Count>i)
                {
                    dziecko = dziecko.Parent.Extensions.ToList()[i];
                    continue;
                }

                dziecko = dziecko.Parent;
                i = dziecko.Parent.Extensions.IndexOf(dziecko);
                i++;
                if (dziecko.Parent.Extensions.ToList().Count > i)
                {
                    dziecko = dziecko.Parent.Extensions.ToList()[i];
                }
                else
                {
                    dziecko = null;
                }
            }
            
        } 
    }
}
</div>

</div>
<div class="clear">
</div>

